#include <iostream>
#include <fstream>
#include <cmath>
#include <complex>
#include <fstream>
#include <sstream>

#include "jednostki.h"
#include "form_faktory_rozdzielnik.h"
#include "tablica_Mef.h"

#include "calg.h"
#include "density_of_nucleus.h"
#include "rpa_lib.h"
#include "../calg5.h"
#include "../util2.h"
#include "../ff.h"

//~ #ifndef RPA_MAIN
	//~ #include "../ff.h"
//~ #endif



double Meff(double kf)
{
	static const double MEF[3000]= 
	{
		938.919,938.918,938.918,938.918,938.917,938.915,938.913,938.909,938.904,
		938.899,938.891,938.882,938.871,938.858,938.843,938.826,938.806,938.784,
		938.759,938.731,938.699,938.665,938.627,938.585,938.54,938.491,938.437,
		938.38,938.318,938.251,938.179,938.103,938.021,937.935,937.843,937.745,
		937.641,937.532,937.417,937.295,937.167,937.032,936.891,936.743,936.587,
		936.425,936.255,936.077,935.892,935.699,935.498,935.289,935.072,934.845,
		934.611,934.367,934.114,933.853,933.582,933.301,933.011,932.711,932.401,
		932.08,931.75,931.409,931.057,930.695,930.322,929.937,929.541,929.134,
		928.716,928.285,927.843,927.388,926.921,926.442,925.951,925.446,924.929,
		924.399,923.855,923.298,922.728,922.144,921.546,920.934,920.308,919.667,
		919.012,918.343,917.658,916.959,916.245,915.515,914.77,914.009,913.233,
		912.44,911.632,910.807,909.966,909.109,908.235,907.344,906.436,905.511,
		904.568,903.608,902.631,901.635,900.622,899.591,898.541,897.473,896.387,
		895.282,894.157,893.014,891.852,890.671,889.47,888.249,887.009,885.749,
		884.469,883.168,881.848,880.506,879.144,877.762,876.358,874.933,873.488,
		872.02,870.531,869.021,867.489,865.934,864.358,862.76,861.139,859.495,
		857.829,856.14,854.429,852.694,850.936,849.155,847.35,845.521,843.669,
		841.793,839.893,837.969,836.021,834.048,832.051,830.029,827.983,825.911,
		823.815,821.694,819.547,817.375,815.177,812.954,810.706,808.431,806.131,
		803.805,801.452,799.074,796.669,794.237,791.78,789.295,786.784,784.246,
		781.682,779.09,776.472,773.826,771.153,768.453,765.726,762.972,760.19,
		757.38,754.543,751.679,748.787,745.867,742.92,739.944,736.942,733.911,
		730.853,727.767,724.653,721.511,718.341,715.144,711.919,708.667,705.386,
		702.078,698.743,695.38,691.99,688.572,685.127,681.654,678.155,674.628,
		671.075,667.495,663.889,660.256,656.596,652.911,649.2,645.463,641.701,
		637.913,634.101,630.264,626.402,622.516,618.607,614.674,610.718,606.74,
		602.739,598.716,594.671,590.606,586.52,582.414,578.288,574.144,569.981,
		565.8,561.603,557.388,553.158,548.913,544.653,540.38,536.093,531.795,
		527.486,523.166,518.837,514.499,510.154,505.802,501.445,497.083,492.718,
		488.351,483.983,479.615,475.248,470.883,466.522,462.166,457.816,453.474,
		449.14,444.817,440.505,436.205,431.92,427.65,423.397,419.162,414.947,
		410.752,406.579,402.43,398.305,394.206,390.134,386.091,382.077,378.094,
		374.142,370.223,366.338,362.488,358.673,354.895,351.154,347.452,343.788,
		340.163,336.579,333.035,329.532,326.071,322.652,319.275,315.94,312.648,
		309.399,306.193,303.03,299.91,296.833,293.799,290.808,287.859,284.953,
		282.088,279.266,276.485,273.746,271.048,268.39,265.772,263.193,260.655,
		258.154,255.692,253.268,250.881,248.531,246.217,243.939,241.696,239.488,
		237.313,235.172,233.065,230.989,228.946,226.933,224.952,223,221.079,
		219.186,217.323,215.487,213.679,211.898,210.143,208.415,206.712,205.034,
		203.381,201.752,200.146,198.564,197.005,195.467,193.952,192.459,190.986,
		189.534,188.102,186.69,185.298,183.925,182.57,181.234,179.916,178.616,
		177.333,176.066,174.817,173.584,172.367,171.166,169.98,168.81,167.654,
		166.513,165.386,164.274,163.175,162.09,161.018,159.959,158.913,157.88,
		156.859,155.85,154.853,153.868,152.894,151.932,150.981,150.041,149.111,
		148.192,147.284,146.385,145.497,144.618,143.75,142.89,142.04,141.2,
		140.368,139.545,138.731,137.926,137.129,136.34,135.56,134.788,134.023,
		133.267,132.518,131.777,131.043,130.317,129.597,128.885,128.18,127.482,
		126.791,126.106,125.428,124.757,124.092,123.433,122.78,122.134,121.493,
		120.859,120.23,119.607,118.99,118.379,117.773,117.173,116.578,115.988,
		115.403,114.824,114.25,113.68,113.116,112.557,112.002,111.453,110.908,
		110.367,109.831,109.3,108.773,108.251,107.733,107.219,106.709,106.204,
		105.703,105.206,104.712,104.223,103.738,103.257,102.779,102.305,101.836,
		101.369,100.907,100.448,99.9921,99.5401,99.0916,98.6466,98.205,97.7667,
		97.3317,96.9001,96.4716,96.0464,95.6243,95.2054,94.7896,94.3768,93.9671,
		93.5604,93.1566,92.7557,92.3578,91.9627,91.5704,91.181,90.7943,90.4104,
		90.0292,89.6506,89.2748,88.9015,88.5308,88.1628,87.7972,87.4342,87.0737,
		86.7156,86.36,86.0068,85.656,85.3075,84.9614,84.6177,84.2762,83.937,
		83.6,83.2653,82.9327,82.6024,82.2742,81.9482,81.6242,81.3024,80.9827,
		80.665,80.3494,80.0357,79.7241,79.4145,79.1068,78.8011,78.4972,78.1953,
		77.8953,77.5972,77.3009,77.0065,76.7138,76.423,76.134,75.8467,75.5612,
		75.2775,74.9954,74.7151,74.4365,74.1595,73.8842,73.6105,73.3385,73.0681,
		72.7993,72.5321,72.2665,72.0025,71.7399,71.479,71.2195,70.9616,70.7051,
		70.4502,70.1967,69.9447,69.6941,69.445,69.1972,68.9509,68.706,68.4625,
		68.2204,67.9796,67.7402,67.5021,67.2653,67.0299,66.7958,66.563,66.3314,
		66.1012,65.8722,65.6445,65.418,65.1928,64.9687,64.746,64.5244,64.304,
		64.0848,63.8668,63.65,63.4343,63.2198,63.0064,62.7941,62.583,62.373,
		62.1641,61.9564,61.7497,61.5441,61.3395,61.1361,60.9337,60.7323,60.532,
		60.3328,60.1345,59.9373,59.7411,59.5459,59.3517,59.1585,58.9663,58.7751,
		58.5848,58.3955,58.2071,58.0197,57.8333,57.6478,57.4632,57.2795,57.0968,
		56.9149,56.734,56.5539,56.3748,56.1965,56.0191,55.8426,55.6669,55.4921,
		55.3182,55.1451,54.9728,54.8014,54.6308,54.4611,54.2921,54.124,53.9567,
		53.7902,53.6244,53.4595,53.2954,53.132,52.9694,52.8076,52.6465,52.4863,
		52.3267,52.1679,52.0099,51.8526,51.696,51.5402,51.3851,51.2307,51.077,
		50.924,50.7718,50.6202,50.4694,50.3192,50.1697,50.021,49.8728,49.7254,
		49.5786,49.4326,49.2871,49.1423,48.9982,48.8548,48.7119,48.5698,48.4282,
		48.2873,48.147,48.0074,47.8683,47.7299,47.5921,47.4549,47.3184,47.1824,
		47.047,46.9122,46.778,46.6444,46.5114,46.379,46.2471,46.1158,45.9851,
		45.855,45.7254,45.5964,45.4679,45.34,45.2126,45.0858,44.9595,44.8338,
		44.7086,44.584,44.4598,44.3362,44.2132,44.0906,43.9686,43.8471,43.7261,
		43.6056,43.4856,43.3661,43.2471,43.1286,43.0107,42.8932,42.7761,42.6596,
		42.5436,42.428,42.313,42.1984,42.0842,41.9706,41.8574,41.7446,41.6324,
		41.5206,41.4092,41.2983,41.1879,41.0779,40.9683,40.8592,40.7506,40.6424,
		40.5346,40.4272,40.3203,40.2138,40.1078,40.0021,39.8969,39.7921,39.6877,
		39.5838,39.4802,39.3771,39.2744,39.1721,39.0701,38.9686,38.8675,38.7668,
		38.6665,38.5666,38.467,38.3679,38.2691,38.1708,38.0728,37.9752,37.8779,
		37.7811,37.6846,37.5885,37.4928,37.3974,37.3024,37.2078,37.1135,37.0196,
		36.9261,36.8329,36.7401,36.6476,36.5555,36.4637,36.3723,36.2812,36.1904,
		36.1001,36.01,35.9203,35.8309,35.7419,35.6532,35.5648,35.4768,35.3891,
		35.3017,35.2146,35.1279,35.0415,34.9554,34.8697,34.7842,34.6991,34.6143,
		34.5297,34.4456,34.3617,34.2781,34.1948,34.1119,34.0292,33.9468,33.8648,
		33.783,33.7016,33.6204,33.5395,33.459,33.3787,33.2987,33.219,33.1396,
		33.0604,32.9816,32.903,32.8248,32.7468,32.669,32.5916,32.5144,32.4375,
		32.3609,32.2846,32.2085,32.1327,32.0572,31.9819,31.9069,31.8322,31.7577,
		31.6835,31.6096,31.5359,31.4624,31.3893,31.3164,31.2437,31.1713,31.0991,
		31.0272,30.9556,30.8842,30.813,30.7421,30.6715,30.601,30.5309,30.4609,
		30.3912,30.3218,30.2526,30.1836,30.1149,30.0463,29.9781,29.91,29.8422,
		29.7747,29.7073,29.6402,29.5733,29.5067,29.4402,29.374,29.308,29.2423,
		29.1767,29.1114,29.0463,28.9814,28.9168,28.8523,28.7881,28.7241,28.6603,
		28.5967,28.5333,28.4701,28.4072,28.3444,28.2819,28.2196,28.1574,28.0955,
		28.0338,27.9723,27.911,27.8499,27.789,27.7283,27.6678,27.6075,27.5473,
		27.4874,27.4277,27.3682,27.3088,27.2497,27.1908,27.132,27.0734,27.0151,
		26.9569,26.8989,26.8411,26.7835,26.726,26.6688,26.6117,26.5548,26.4981,
		26.4416,26.3852,26.3291,26.2731,26.2173,26.1617,26.1062,26.0509,25.9959,
		25.9409,25.8862,25.8316,25.7772,25.723,25.6689,25.615,25.5613,25.5078,
		25.4544,25.4012,25.3481,25.2952,25.2425,25.19,25.1376,25.0853,25.0333,
		24.9814,24.9296,24.8781,24.8267,24.7754,24.7243,24.6734,24.6226,24.5719,
		24.5215,24.4711,24.421,24.371,24.3211,24.2714,24.2219,24.1725,24.1232,
		24.0741,24.0252,23.9764,23.9277,23.8792,23.8309,23.7827,23.7346,23.6867,
		23.6389,23.5913,23.5438,23.4965,23.4493,23.4022,23.3553,23.3085,23.2619,
		23.2154,23.1691,23.1228,23.0768,23.0308,22.985,22.9394,22.8938,22.8484,
		22.8032,22.758,22.713,22.6682,22.6235,22.5789,22.5344,22.4901,22.4459,
		22.4018,22.3579,22.314,22.2704,22.2268,22.1834,22.1401,22.0969,22.0538,
		22.0109,21.9681,21.9254,21.8829,21.8405,21.7982,21.756,21.7139,21.672,
		21.6302,21.5885,21.5469,21.5055,21.4641,21.4229,21.3818,21.3408,21.3,
		21.2592,21.2186,21.1781,21.1377,21.0974,21.0572,21.0172,20.9772,20.9374,
		20.8977,20.8581,20.8186,20.7792,20.74,20.7008,20.6618,20.6229,20.584,
		20.5453,20.5067,20.4682,20.4298,20.3916,20.3534,20.3153,20.2774,20.2395,
		20.2018,20.1641,20.1266,20.0892,20.0518,20.0146,19.9775,19.9405,19.9035,
		19.8667,19.83,19.7934,19.7569,19.7205,19.6842,19.648,19.6119,19.5759,
		19.54,19.5041,19.4684,19.4328,19.3973,19.3619,19.3266,19.2913,19.2562,
		19.2212,19.1862,19.1514,19.1166,19.082,19.0474,19.0129,18.9786,18.9443,
		18.9101,18.876,18.842,18.8081,18.7742,18.7405,18.7069,18.6733,18.6399,
		18.6065,18.5732,18.54,18.5069,18.4739,18.441,18.4081,18.3754,18.3427,
		18.3101,18.2776,18.2452,18.2129,18.1807,18.1485,18.1165,18.0845,18.0526,
		18.0208,17.989,17.9574,17.9258,17.8944,17.863,17.8317,17.8004,17.7693,
		17.7382,17.7072,17.6763,17.6455,17.6147,17.5841,17.5535,17.523,17.4926,
		17.4622,17.432,17.4018,17.3717,17.3416,17.3117,17.2818,17.252,17.2223,
		17.1926,17.163,17.1335,17.1041,17.0748,17.0455,17.0163,16.9872,16.9582,
		16.9292,16.9003,16.8715,16.8427,16.814,16.7854,16.7569,16.7284,16.7001,
		16.6717,16.6435,16.6153,16.5872,16.5592,16.5313,16.5034,16.4755,16.4478,
		16.4201,16.3925,16.365,16.3375,16.3101,16.2828,16.2555,16.2283,16.2012,
		16.1741,16.1472,16.1202,16.0934,16.0666,16.0399,16.0132,15.9866,15.9601,
		15.9336,15.9072,15.8809,15.8546,15.8285,15.8023,15.7763,15.7502,15.7243,
		15.6984,15.6726,15.6469,15.6212,15.5956,15.57,15.5445,15.5191,15.4937,
		15.4684,15.4431,15.4179,15.3928,15.3678,15.3428,15.3178,15.2929,15.2681,
		15.2433,15.2186,15.194,15.1694,15.1449,15.1204,15.096,15.0717,15.0474,
		15.0232,14.999,14.9749,14.9508,14.9268,14.9029,14.879,14.8552,14.8314,
		14.8077,14.7841,14.7605,14.7369,14.7134,14.69,14.6666,14.6433,14.6201,
		14.5969,14.5737,14.5506,14.5276,14.5046,14.4816,14.4588,14.4359,14.4132,
		14.3904,14.3678,14.3452,14.3226,14.3001,14.2777,14.2553,14.2329,14.2106,
		14.1884,14.1662,14.144,14.122,14.0999,14.0779,14.056,14.0341,14.0123,
		13.9905,13.9688,13.9471,13.9255,13.9039,13.8824,13.8609,13.8395,13.8181,
		13.7968,13.7755,13.7543,13.7331,13.7119,13.6909,13.6698,13.6488,13.6279,
		13.607,13.5861,13.5654,13.5446,13.5239,13.5032,13.4826,13.4621,13.4416,
		13.4211,13.4007,13.3803,13.36,13.3397,13.3195,13.2993,13.2791,13.259,
		13.239,13.219,13.199,13.1791,13.1592,13.1394,13.1196,13.0999,13.0802,
		13.0605,13.0409,13.0214,13.0018,12.9824,12.9629,12.9436,12.9242,12.9049,
		12.8857,12.8664,12.8473,12.8281,12.8091,12.79,12.771,12.7521,12.7331,
		12.7143,12.6954,12.6766,12.6579,12.6392,12.6205,12.6019,12.5833,12.5648,
		12.5463,12.5278,12.5094,12.491,12.4726,12.4543,12.4361,12.4179,12.3997,
		12.3815,12.3634,12.3454,12.3274,12.3094,12.2914,12.2735,12.2557,12.2378,
		12.22,12.2023,12.1846,12.1669,12.1493,12.1317,12.1141,12.0966,12.0791,
		12.0617,12.0443,12.0269,12.0096,11.9923,11.975,11.9578,11.9406,11.9235,
		11.9064,11.8893,11.8723,11.8553,11.8383,11.8214,11.8045,11.7876,11.7708,
		11.754,11.7373,11.7206,11.7039,11.6872,11.6706,11.6541,11.6375,11.621,
		11.6046,11.5881,11.5717,11.5554,11.5391,11.5228,11.5065,11.4903,11.4741,
		11.4579,11.4418,11.4257,11.4097,11.3937,11.3777,11.3617,11.3458,11.3299,
		11.3141,11.2983,11.2825,11.2667,11.251,11.2353,11.2197,11.204,11.1885,
		11.1729,11.1574,11.1419,11.1264,11.111,11.0956,11.0802,11.0649,11.0496,
		11.0343,11.0191,11.0039,10.9887,10.9736,10.9585,10.9434,10.9283,10.9133,
		10.8983,10.8834,10.8684,10.8535,10.8387,10.8238,10.809,10.7943,10.7795,
		10.7648,10.7501,10.7355,10.7208,10.7063,10.6917,10.6772,10.6626,10.6482,
		10.6337,10.6193,10.6049,10.5906,10.5762,10.5619,10.5477,10.5334,10.5192,
		10.505,10.4909,10.4767,10.4626,10.4486,10.4345,10.4205,10.4065,10.3925,
		10.3786,10.3647,10.3508,10.337,10.3232,10.3094,10.2956,10.2819,10.2682,
		10.2545,10.2408,10.2272,10.2136,10.2,10.1865,10.173,10.1595,10.146,
		10.1326,10.1191,10.1058,10.0924,10.0791,10.0658,10.0525,10.0392,10.026,
		10.0128,9.99961,9.98646,9.97333,9.96024,9.94716,9.93411,9.92109,9.90809,
		9.89512,9.88218,9.86926,9.85636,9.84349,9.83065,9.81783,9.80503,9.79226,
		9.77952,9.76679,9.7541,9.74143,9.72878,9.71616,9.70356,9.69099,9.67844,
		9.66592,9.65342,9.64094,9.62849,9.61606,9.60366,9.59128,9.57892,9.56659,
		9.55428,9.542,9.52973,9.5175,9.50528,9.49309,9.48093,9.46878,9.45666,
		9.44456,9.43249,9.42044,9.40841,9.3964,9.38442,9.37246,9.36052,9.34861,
		9.33672,9.32485,9.313,9.30118,9.28938,9.2776,9.26584,9.25411,9.2424,
		9.23071,9.21904,9.20739,9.19577,9.18417,9.17259,9.16103,9.14949,9.13798,
		9.12649,9.11502,9.10357,9.09214,9.08073,9.06935,9.05798,9.04664,9.03532,
		9.02402,9.01274,9.00148,8.99024,8.97903,8.96783,8.95666,8.9455,8.93437,
		8.92326,8.91217,8.9011,8.89005,8.87902,8.86801,8.85702,8.84605,8.8351,
		8.82417,8.81327,8.80238,8.79151,8.78066,8.76984,8.75903,8.74824,8.73747,
		8.72673,8.716,8.70529,8.6946,8.68393,8.67328,8.66265,8.65204,8.64145,
		8.63088,8.62033,8.6098,8.59928,8.58879,8.57831,8.56786,8.55742,8.547,
		8.5366,8.52622,8.51586,8.50552,8.49519,8.48489,8.4746,8.46433,8.45409,
		8.44385,8.43364,8.42345,8.41327,8.40312,8.39298,8.38286,8.37276,8.36267,
		8.35261,8.34256,8.33253,8.32252,8.31253,8.30255,8.29259,8.28265,8.27273,
		8.26283,8.25294,8.24307,8.23322,8.22339,8.21357,8.20378,8.194,8.18423,
		8.17449,8.16476,8.15505,8.14535,8.13568,8.12602,8.11637,8.10675,8.09714,
		8.08755,8.07797,8.06842,8.05888,8.04935,8.03985,8.03036,8.02088,8.01143,
		8.00199,7.99257,7.98316,7.97377,7.9644,7.95504,7.9457,7.93637,7.92707,
		7.91777,7.9085,7.89924,7.89,7.88077,7.87156,7.86237,7.85319,7.84403,
		7.83488,7.82575,7.81664,7.80754,7.79846,7.78939,7.78034,7.7713,7.76228,
		7.75328,7.74429,7.73532,7.72636,7.71742,7.70849,7.69958,7.69069,7.68181,
		7.67294,7.66409,7.65526,7.64644,7.63764,7.62885,7.62008,7.61132,7.60257,
		7.59385,7.58513,7.57643,7.56775,7.55908,7.55043,7.54179,7.53317,7.52456,
		7.51596,7.50738,7.49882,7.49027,7.48173,7.47321,7.4647,7.45621,7.44773,
		7.43927,7.43082,7.42238,7.41396,7.40556,7.39717,7.38879,7.38042,7.37208,
		7.36374,7.35542,7.34711,7.33882,7.33054,7.32228,7.31402,7.30579,7.29756,
		7.28935,7.28116,7.27298,7.26481,7.25665,7.24851,7.24039,7.23227,7.22417,
		7.21609,7.20801,7.19995,7.19191,7.18388,7.17586,7.16785,7.15986,7.15188,
		7.14392,7.13596,7.12802,7.1201,7.11219,7.10429,7.0964,7.08853,7.08067,
		7.07282,7.06499,7.05716,7.04936,7.04156,7.03378,7.02601,7.01825,7.01051,
		7.00278,6.99506,6.98735,6.97966,6.97198,6.96431,6.95666,6.94902,6.94139,
		6.93377,6.92616,6.91857,6.91099,6.90343,6.89587,6.88833,6.8808,6.87328,
		6.86577,6.85828,6.8508,6.84333,6.83587,6.82843,6.821,6.81358,6.80617,
		6.79877,6.79139,6.78401,6.77665,6.76931,6.76197,6.75464,6.74733,6.74003,
		6.73274,6.72546,6.7182,6.71095,6.7037,6.69647,6.68925,6.68205,6.67485,
		6.66767,6.6605,6.65334,6.64619,6.63905,6.63192,6.62481,6.6177,6.61061,
		6.60353,6.59646,6.58941,6.58236,6.57532,6.5683,6.56129,6.55428,6.54729,
		6.54032,6.53335,6.52639,6.51944,6.51251,6.50559,6.49867,6.49177,6.48488,
		6.478,6.47113,6.46427,6.45742,6.45059,6.44376,6.43695,6.43014,6.42335,
		6.41657,6.4098,6.40304,6.39629,6.38955,6.38282,6.3761,6.36939,6.36269,
		6.35601,6.34933,6.34266,6.33601,6.32936,6.32273,6.3161,6.30949,6.30289,
		6.29629,6.28971,6.28314,6.27658,6.27002,6.26348,6.25695,6.25043,6.24392,
		6.23742,6.23093,6.22445,6.21798,6.21152,6.20507,6.19862,6.19219,6.18577,
		6.17936,6.17296,6.16657,6.16019,6.15382,6.14746,6.14111,6.13477,6.12844,
		6.12211,6.1158,6.1095,6.10321,6.09692,6.09065,6.08439,6.07813,6.07189,
		6.06565,6.05943,6.05321,6.04701,6.04081,6.03462,6.02845,6.02228,6.01612,
		6.00997,6.00383,5.9977,5.99158,5.98547,5.97937,5.97327,5.96719,5.96111,
		5.95505,5.94899,5.94295,5.93691,5.93088,5.92486,5.91885,5.91285,5.90686,
		5.90087,5.8949,5.88894,5.88298,5.87703,5.8711,5.86517,5.85925,5.85334,
		5.84744,5.84154,5.83566,5.82978,5.82392,5.81806,5.81221,5.80637,5.80054,
		5.79472,5.7889,5.7831,5.7773,5.77152,5.76574,5.75997,5.75421,5.74845,
		5.74271,5.73697,5.73125,5.72553,5.71982,5.71412,5.70842,5.70274,5.69706,
		5.69139,5.68574,5.68008,5.67444,5.66881,5.66318,5.65757,5.65196,5.64636,
		5.64076,5.63518,5.6296,5.62404,5.61848,5.61293,5.60738,5.60185,5.59632,
		5.59081,5.5853,5.57979,5.5743,5.56881,5.56334,5.55787,5.55241,5.54695,
		5.54151,5.53607,5.53064,5.52522,5.5198,5.5144,5.509,5.50361,5.49823,
		5.49286,5.48749,5.48213,5.47678,5.47144,5.4661,5.46078,5.45546,5.45014,
		5.44484,5.43954,5.43426,5.42898,5.4237,5.41844,5.41318,5.40793,5.40269,
		5.39745,5.39223,5.38701,5.38179,5.37659,5.37139,5.3662,5.36102,5.35585,
		5.35068,5.34552,5.34037,5.33522,5.33008,5.32496,5.31983,5.31472,5.30961,
		5.30451,5.29942,5.29433,5.28925,5.28418,5.27912,5.27406,5.26901,5.26397,
		5.25893,5.25391,5.24889,5.24387,5.23887,5.23387,5.22888,5.22389,5.21891,
		5.21394,5.20898,5.20402,5.19907,5.19413,5.1892,5.18427,5.17935,5.17443,
		5.16952,5.16462,5.15973,5.15484,5.14997,5.14509,5.14023,5.13537,5.13052,
		5.12567,5.12083,5.116,5.11118,5.10636,5.10155,5.09674,5.09195,5.08716,
		5.08237,5.0776,5.07283,5.06806,5.0633,5.05855,5.05381,5.04907,5.04434,
		5.03962,5.0349,5.03019,5.02549,5.02079,5.0161,5.01142,5.00674,5.00207,
		4.9974,4.99274,4.98809,4.98345,4.97881,4.97418,4.96955,4.96493,4.96032,
		4.95571,4.95111,4.94652,4.94193,4.93735,4.93278,4.92821,4.92365,4.91909,
		4.91454,4.91,4.90546,4.90093,4.89641,4.89189,4.88738,4.88287,4.87837,
		4.87388,4.8694,4.86491,4.86044,4.85597,4.85151,4.84705,4.8426,4.83816,
		4.83372,4.82929,4.82487,4.82045,4.81603,4.81163,4.80723,4.80283,4.79844,
		4.79406,4.78968,4.78531,4.78094,4.77658,4.77223,4.76788,4.76354,4.75921,
		4.75488,4.75055,4.74624,4.74192,4.73762,4.73332,4.72902,4.72474,4.72045,
		4.71618,4.7119,4.70764,4.70338,4.69913,4.69488,4.69064,4.6864,4.68217,
		4.67794,4.67372,4.66951,4.6653,4.6611,4.6569,4.65271,4.64853,4.64435,
		4.64017,4.636,4.63184,4.62768,4.62353,4.61939,4.61525,4.61111,4.60698,
		4.60286,4.59874,4.59463,4.59052,4.58642,4.58232,4.57823,4.57414,4.57006,
		4.56599,4.56192,4.55786,4.5538,4.54975,4.5457,4.54166,4.53762,4.53359,
		4.52956,4.52554,4.52153,4.51752,4.51351,4.50951,4.50552,4.50153,4.49755,
		4.49357,4.4896,4.48563,4.48167,4.47771,4.47376,4.46981,4.46587,4.46193,
		4.458,4.45408,4.45016,4.44624,4.44233,4.43843,4.43453,4.43063,4.42674,
		4.42286,4.41898,4.4151,4.41123,4.40737,4.40351,4.39965,4.39581,4.39196,
		4.38812,4.38429,4.38046,4.37664,4.37282,4.369,4.36519,4.36139,4.35759,
		4.3538,4.35001,4.34622,4.34244,4.33867,4.3349,4.33113,4.32738,4.32362,
		4.31987,4.31613,4.31238,4.30865,4.30492,4.30119,4.29747,4.29376,4.29005,
		4.28634,4.28264,4.27894,4.27525,4.27156,4.26788,4.2642,4.26053,4.25686,
		4.2532,4.24954,4.24588,4.24223,4.23859,4.23495,4.23131,4.22768,4.22406,
		4.22044,4.21682,4.21321,4.2096,4.206,4.2024,4.1988,4.19522,4.19163,
		4.18805,4.18448,4.18091,4.17734,4.17378,4.17022,4.16667,4.16312,4.15958,
		4.15604,4.1525,4.14897,4.14545,4.14193,4.13841,4.1349,4.13139,4.12789,
		4.12439,4.1209,4.11741,4.11392,4.11044,4.10696,4.10349,4.10002,4.09656,
		4.0931,4.08965,4.0862,4.08275,4.07931,4.07587,4.07244,4.06901,4.06559,
		4.06217,4.05875,4.05534,4.05193,4.04853,4.04513,4.04174,4.03835,4.03496,
		4.03158,4.0282,4.02483,4.02146,4.0181,4.01474,4.01138,4.00803,4.00468,
		4.00134,3.998,3.99467,3.99133,3.98801,3.98469,3.98137,3.97805,3.97474,
		3.97144,3.96813,3.96484,3.96154,3.95825,3.95497,3.95169,3.94841,3.94514,
		3.94187,3.9386,3.93534,3.93208,3.92883,3.92558,3.92234,3.9191,3.91586,
		3.91263,3.9094,3.90617,3.90295,3.89973,3.89652,3.89331,3.89011,3.88691,
		3.88371,3.88051,3.87733,3.87414,3.87096,3.86778,3.86461,3.86144,3.85827,
		3.85511,3.85195,3.8488,3.84565,3.8425,3.83936,3.83622,3.83308,3.82995,
		3.82683,3.8237,3.82058,3.81747,3.81435,3.81125,3.80814,3.80504,3.80194,
		3.79885,3.79576,3.79268,3.78959,3.78652,3.78344,3.78037,3.7773,3.77424,
		3.77118,3.76813,3.76507,3.76203,3.75898,3.75594,3.7529,3.74987,3.74684,
		3.74381,3.74079,3.73777,3.73476,3.73175,3.72874,3.72573,3.72273,3.71974,
		3.71674,3.71375,3.71077,3.70778,3.7048,3.70183,3.69886,3.69589,3.69292,
		3.68996,3.68701,3.68405,3.6811,3.67815,3.67521,3.67227,3.66933,3.6664,
		3.66347,3.66055,3.65762,3.6547,3.65179,3.64888,3.64597,3.64306,3.64016,
		3.63726,3.63437,3.63148,3.62859,3.62571,3.62282,3.61995,3.61707,3.6142,
		3.61134,3.60847,3.60561,3.60275,3.5999,3.59705,3.5942,3.59136,3.58852,
		3.58568,3.58285,3.58002,3.57719,3.57437,3.57155,3.56873,3.56592,3.56311,
		3.5603,3.5575,3.5547,3.5519,3.54911,3.54632,3.54353,3.54075,3.53797,
		3.53519,3.53242,3.52965,3.52688,3.52412,3.52136,3.5186,3.51584,3.51309,
		3.51035,3.5076,3.50486,3.50212,3.49939,3.49665,3.49393,3.4912,3.48848,
		3.48576,3.48304,3.48033,3.47762,3.47491,3.47221,3.46951,3.46681,3.46412,
		3.46143,3.45874,3.45606,3.45338,3.4507,3.44802,3.44535,3.44268,3.44002,
		3.43735,3.43469,3.43204,3.42938,3.42673,3.42409,3.42144,3.4188,3.41616,
		3.41353,3.4109,3.40827,3.40564,3.40302,3.4004,3.39778,3.39517,3.39256,
		3.38995,3.38734,3.38474,3.38214,3.37955,3.37695,3.37436,3.37178,3.36919,
		3.36661,3.36403,3.36146,3.35889,3.35632,3.35375,3.35119,3.34863,3.34607,
		3.34352,3.34096,3.33842,3.33587,3.33333,3.33079,3.32825,3.32572,3.32319,
		3.32066,3.31813,3.31561,3.31309,3.31057,3.30806,3.30555,3.30304,3.30053,
		3.29803,3.29553,3.29303,3.29054,3.28805,3.28556,3.28307,3.28059,3.27811,
		3.27563,3.27316,3.27069,3.26822,3.26575,3.26329,3.26083,3.25837,3.25592,
		3.25347,3.25102,3.24857,3.24613,3.24368,3.24125,3.23881,3.23638,3.23395,
		3.23152,3.2291,3.22667,3.22426,3.22184,3.21943,3.21701,3.21461,3.2122,
		3.2098,3.2074,3.205,3.2026,3.20021,3.19782,3.19544,3.19305,3.19067,
		3.18829,3.18592,3.18354,3.18117,3.1788,3.17644,3.17407,3.17171,3.16936,
		3.167,3.16465,3.1623,3.15995,3.15761,3.15526,3.15293,3.15059,3.14825,
		3.14592,3.14359,3.14127,3.13894,3.13662,3.1343,3.13199,3.12967,3.12736,
		3.12505,3.12275,3.12044,3.11814,3.11585,3.11355,3.11126,3.10897,3.10668,
		3.10439,3.10211,3.09983,3.09755,3.09527,3.093,3.09073,3.08846,3.0862,
		3.08393,3.08167,3.07942,3.07716,3.07491,3.07266,3.07041,3.06816,3.06592,
		3.06368,3.06144,3.0592,3.05697,3.05474,3.05251,3.05028,3.04806,3.04584,
		3.04362,3.0414,3.03919,3.03698,3.03477,3.03256,3.03036,3.02815,3.02595,
		3.02376,3.02156,3.01937,3.01718,3.01499,3.01281,3.01062,3.00844,3.00627,
		3.00409,3.00192,2.99974,2.99758,2.99541,2.99325,2.99108,2.98892,2.98677,
		2.98461,2.98246,2.98031,2.97816,2.97602,2.97387,2.97173,2.96959,2.96746,
		2.96532,2.96319,2.96106,2.95894,2.95681,2.95469,2.95257,2.95045,2.94834,
		2.94622,2.94411,2.942,2.9399,2.93779,2.93569,2.93359,2.93149,2.9294,
		2.9273,2.92521,2.92312,2.92104,2.91895,2.91687,2.91479,2.91271,2.91064,
		2.90857,2.9065,2.90443,2.90236,2.9003,2.89823,2.89617,2.89412,2.89206,
		2.89001,2.88796,2.88591,2.88386,2.88182,2.87978,2.87773,2.8757,2.87366,
		2.87163,2.8696,2.86757,2.86554,2.86351,2.86149,2.85947,2.85745,2.85544,
		2.85342,2.85141,2.8494,2.84739,2.84538,2.84338,2.84138,2.83938,2.83738,
		2.83539,2.83339,2.8314,2.82941,2.82743,2.82544,2.82346,2.82148,2.8195,
		2.81752,2.81555,2.81358,2.81161,2.80964,2.80767,2.80571,2.80375,2.80179,
		2.79983,2.79787,2.79592,2.79397,2.79202,2.79007,2.78812,2.78618,2.78424,
		2.7823,2.78036,2.77843,2.77649,2.77456,2.77263,2.7707,2.76878,2.76685,
		2.76493,2.76301,2.7611,2.75918,2.75727,2.75536,2.75345,2.75154,2.74963,
		2.74773,2.74583,2.74393,2.74203,2.74013,2.73824,2.73635,2.73446,2.73257,
		2.73069,2.7288,2.72692,2.72504,2.72316,2.72129,2.71941,2.71754,2.71567,
		2.7138,2.71193,2.71007,2.70821,2.70634,2.70449,2.70263,2.70077,2.69892,
		2.69707,2.69522,2.69337,2.69153,2.68968,2.68784,2.686,2.68416,2.68233,
		2.68049,2.67866,2.67683,2.675,2.67318,2.67135,2.66953,2.66771,2.66589,
		2.66407,2.66226,2.66044,2.65863,2.65682,2.65501,2.65321,2.6514,2.6496,
		2.6478,2.646,2.6442,2.64241,2.64061,2.63882,2.63703,2.63524,2.63346,
		2.63167,2.62989,2.62811,2.62633,2.62455,2.62278,2.621,2.61923,2.61746,
		2.61569,2.61393,2.61216,2.6104,2.60864,2.60688,2.60512,2.60337,2.60161,
		2.59986,2.59811,2.59636,2.59462,2.59287,2.59113,2.58939,2.58765,2.58591,
		2.58417,2.58244,2.5807,2.57897,2.57724,2.57552,2.57379,2.57207,2.57034,
		2.56862,2.5669,2.56519,2.56347,2.56176,2.56005,2.55834,2.55663,2.55492,
		2.55322,2.55151,2.54981,2.54811,2.54641,2.54471,2.54302,2.54133,2.53963,
		2.53794,2.53626,2.53457
	};

	int i = int(kf);
	double x = kf-i;

	if(i>2999)
		return 2;//or maybe tablica_Mef[2999];
	else 
		return  MEF[i]*(1-x) + MEF[i+1]*x;
}


namespace rpa
{
	using namespace std;

	typedef complex<double> zesp;
	
	double Przekroj(double qv,double q0);
	
	double M=M12;             
	double M12_2=M12*M12;
	//double magneton=4.71;      
	double m_pi2= m_pi*m_pi;
	double m_r2 =m_r*m_r;
	double gr =sqrt(1.64*4*Pi); 
	double gr2=gr*gr;
	double fr = 6.1*gr;          
	double fr2 =fr*fr;
	double fpi = sqrt(4*Pi*0.075);
	double fpi2= fpi*fpi;
	double g_prim = 0.7;           
	bool ratio=false;      // used by ratio_rpa_fg;
	double En;             // changed by configure  
	int kFF=Dipol;             // changed by configure
	double kf=225;             // changed by configure 
	int znak = -1;   	   // changed by configure 
						   // znak = 1 - particle 
						   // znak =-1 - antiparticle
	double m=m_mu;         // changed by configure
	double mm = m*m;       // changed by configure
	double mm2=mm;
	bool use_rpa = true;   // changed by configure
	double Mef=M;            // changed by configure
	double Mef2=Mef*Mef;    // changed by configure      
	double Ef2=kf*kf+Mef2;  // changed by configure
	double Ef=sqrt(Ef2);            // changed by configure
	double sqrt_2=sqrt(2);

	int lambda_l =1;     
	 
	int l(1), t(1);
	
	 
	double max3(double a, double b, double c)
	{  
		return max(a,max(b,c));
	}

				
	double qMin(double q0)
	{      
		if( ((En-q0)*(En-q0)-mm) <= 0 ) 
			return 0;  
		else
			return sqrt(2*En*En-2*En*q0+q0*q0-mm-2*En*sqrt((En-q0)*(En-q0)-mm ));
			
	}

	double qMax(double q0)
	{
		if((En-q0)*(En-q0)-mm <= 0 ) 
			return 0;	  
		else
			return sqrt(2*En*En - 2*En*q0 + q0*q0 - mm + 2*En*sqrt((En-q0)*(En-q0)-mm ));
	}

	double qMin2(double q0)
	{
		return 2*En*En - 2*En*q0 + q0*q0 - mm - 2*En*sqrt((En-q0)*(En-q0)-mm );
	}


	double stala = 1.14e-11;   /// tak bylo

	//double stala = G*0.9737;

	double sigma_qv_q0(double qv,double q0)
	{
	//    cout<<"En="<<En/MeV<<endl;
	//    cout<<"qv="<<qv/MeV<<endl;
	//    cout<<"q0="<<q0/MeV<<endl;
		double q02=q0*q0;
		double q04=q02*q02;
		double qv2=qv*qv;
		double qv4=qv2*qv2;
		double qv3=qv2*qv;
		double q2 = q02-qv2;
		double q4 =q2*q2;

		double alfa=log(fabs(q4 - 4*pow( q0*Ef - qv*kf, 2 ) )/fabs(q4 - 4*pow(q0*Ef + qv*kf,  2)) );
		double beta=log(fabs((pow(q2 + 2*qv*kf, 2) - 4*q02*Ef2))/fabs(pow(q2 - 2*qv*kf, 2) - 4*q02*Ef2 ) ) ;
		double stal=sqrt(q2*(q2 -4*Mef2));
		double czynnik1=fabs(q4*Ef - 4*q0*Mef2*(q0*Ef-qv*kf) - kf*q2*stal)/fabs(q4*Ef - 4*q0*Mef2*(q0*Ef-qv*kf) + kf*q2*stal);
		double czynnik2=fabs(q4*Ef - 4*q0*Mef2*(q0*Ef+qv*kf) - kf*q2*stal)/fabs(q4*Ef - 4*q0*Mef2*(q0*Ef+qv*kf) + kf*q2*stal);

		double LAMBDA =(log(czynnik1 ) + log(czynnik2)  )/2/stal; 



		double nawias_ReHs = kf*Ef - (3*Mef2 - q2/2)*log((kf+Ef)/Mef) - q0*(4*Mef2-q2)*alfa/8/qv + 
									Ef*(4*Mef2-q2)*beta/4/qv +(4*Mef2-q2)*(4*Mef2-q2)*LAMBDA/4; 
		double ReHs= lambda_l*nawias_ReHs /2/Pi/Pi;
		double nawias_ReHl= 2*kf*Ef/3 - (qv2/6)*log((kf+Ef)/Mef) + (q0/(4*qv))*(Ef2 + (q02-3*qv2)/12 )*alfa 
			- Ef*(3*q2 + 4*Ef2)*beta/(24*qv) + qv2*(2*Mef2+q2)*(4*Mef2-q2)*LAMBDA/12/q2 ;
		double ReHl=nawias_ReHl*lambda_l*q2/Pi/Pi/qv2; 
		double nawias_ReHt= kf*Ef*(1+ 2*q02/qv2 )/3 + (q2/3)*log((kf+Ef)/Mef)
			+ (q0*q2/(4*qv3))*((q02 + 3*qv2)/12 + qv2*Mef2/q2+ Ef2)*alfa
			+ (Ef/qv)*((qv4-q04)/(8*qv2) - Mef2/2 - q2*Ef2/(6*qv2))*beta
			-  (2*Mef2+q2)*(4*Mef2 - q2)*LAMBDA/6; 

		double ReHt= 2*nawias_ReHt*lambda_l/2/Pi/Pi; 
		double ReH0=(qv*kf + q0*Ef*alfa/2 -(q2/8 + Ef2/2 + qv2*Mef2/(2*q2))*beta)* lambda_l*Mef/(2*Pi*Pi*qv);


		double E_=min(Ef, max3( Mef , Ef - q0, 0.5*(- q0+qv * sqrt(1-4*Mef2/q2 ))));                     
		double E1= Ef - E_; 
		double E2=(Ef*Ef -E_*E_)/2;
		double E3=(Ef*Ef*Ef -E_*E_*E_)/3; 
				 

		double Re_H_a=( - 2*ReHs - ReHl + ReHt)/3;
		double Re_H_vv_l=ReHl;
		double Re_H_vv_t=ReHt;
		double Re_H_va=q2*ReH0/2/qv/qv/Mef;
		double Re_H_tt_l=q2*( -ReHl + ReHs - 2*ReHt)/ 12 / M/M;
		double nawias1_Re_H_tt_t = ReHl*(q2 - 8*Mef2) + ReHt*(2*Mef2 - q2) + 2*ReHs*(q2-2*Mef2);
		double nawias2_Re_H_tt_t = q2*ReH0 - 2*qv*qv*Mef*Re_H_va;
		double Re_H_tt_t=q2*(nawias1_Re_H_tt_t/24/M/M/Mef2 + nawias2_Re_H_tt_t/4/q0/M/M/Mef);
		double Re_H_vt_l=-q2*Re_H_a/4/M/Mef;
		double Re_H_vt_t=q2*Re_H_a/2/M/Mef ;

		double Im_H_vv_l=(q2/(2*Pi*qv3))*( E3 + q0*E2 + q2*E1/4 ) ; 
		double Im_H_vv_t=2*(q2/(4*Pi*qv3))*(E3+q0*E2+(qv2*Mef2/q2+0.25*(q02+qv2))*E1) ;
		double Im_H_tt_l=- ( q2/( 8*Pi*qv3*M*M))*( q2*E3 + q0*q2*E2+( qv2*Mef2 +0.25*q2*q02 )*E1 );
		double Im_H_tt_t=( q2/(8*Pi*qv3*M*M) )*(  (Mef2*qv2- 0.25*q4)*E1- q0*q2*E2 -q2*E3 ) ;
		double Im_H_vt_l=- q2*E1*Mef /(8*Pi*qv*M); 
		double Im_H_vt_t= -2*Im_H_vt_l;                             // dwojka
		double Im_H_va=qv*(q2/(8*Pi*qv3))*(2*E2 + q0*E1);
		double Im_H_a=(Mef2 * E1 )/(2*Pi*qv);

		zesp H_vv_l=zesp(Re_H_vv_l,Im_H_vv_l); 
		zesp H_vv_t=-0.5* zesp(Re_H_vv_t,Im_H_vv_t); 
		zesp H_tt_l=zesp(Re_H_tt_l,Im_H_tt_l); 
		zesp H_tt_t=-0.5*zesp(Re_H_tt_t,Im_H_tt_t); 
		zesp H_vt_l=      zesp(Re_H_vt_l,Im_H_vt_l); 
		zesp H_vt_t= -0.5*zesp(Re_H_vt_t,Im_H_vt_t); 
		zesp H_va  =  zesp(qv*Re_H_va, Im_H_va) ;
		zesp H_a   =  zesp(Re_H_a,Im_H_a); 

		zesp H_rr_l=(0.5*gr2*H_vv_l + fr*gr*H_vt_l + 0.5*fr2*H_tt_l);
		zesp H_rr_t=(0.5*gr2*H_vv_t + fr*gr*H_vt_t + 0.5*fr2*H_tt_t);
		zesp H_rp_va=-fpi*(gr + fr *Mef/M)*H_va/m_pi;
		zesp H_pp_l=2.*fpi2*H_vv_l/m_pi2;
		zesp H_pp_t=2.*fpi2*H_vv_t/m_pi2;
		zesp H_pp_a=2.*fpi2*H_a/m_pi2;

		double MA= 1.03*GeV;
		double MV2=0.71*GeV*GeV;
//		double G_E= 1/( pow((1-q2/MV2),2) ); 
//		double G_M=G_E*magneton ;       
//#ifdef RPA_MAIN		
		double F_1_= F_1(-q2,kFF);//(q2*G_M - 4*M12_2*G_E )/(q2 - 4*M12_2) ;
		double F_2_= F_2(-q2,kFF);//4*M12_2*( G_M - G_E )/(4*M12_2 - q2);    
		double G_A_= G_A(-q2,kFF); //-1.26/(pow(1-q2/(MA*MA),2));                 
//#else
		//~ params p;
		//~ ff_configure(p);
		//~ double F_1_,F_2_,G_A_,F_P_;
		//~ list(F_1_,F_2_)=f12(q2,0); // 0-cc, 1-nc proton, 2-nc neutron  
		//~ list(G_A_,F_P_)=fap(q2,0);
//#endif

		double V_l=- q2/(q2 - m_pi2);
		double V_t=V_l;                                        	        
		double V_a=-V_l - g_prim;
		double R_t= -q2/(q2 - m_r2)/m_r2;              
		double R_a=1/m_r2;
		double R_l= R_t;      

		double R_ta=R_t+R_a;
		double R_la=R_l+R_a;
		double V_ta=V_t+V_a;
		double V_la=V_l+V_a;

		zesp H_r_l= gr*(F_1_*H_vv_l + F_2_*H_vt_l)/sqrt_2+
				  fr*(F_1_*H_vt_l + F_2_*H_tt_l)/sqrt_2;

		zesp H_r_t=gr*(F_1_*H_vv_t + F_2_*H_vt_t)/sqrt_2 + fr*(F_1_*H_vt_t + F_2_*H_tt_t)/sqrt_2;

		zesp H_r_va=G_A_*(gr+fr*Mef/M)*H_va/sqrt_2;
		  
		zesp H_p_l= -sqrt_2*fpi*G_A_*H_vv_l/m_pi;
		  
		zesp H_p_t= -sqrt_2*fpi*G_A_*H_vv_t/m_pi;

		zesp H_p_va= -sqrt_2*fpi*(F_1_+F_2_*Mef/M)*H_va/m_pi;
	 
		zesp H_p_a=-sqrt_2*fpi*H_a*G_A_/m_pi;
	  
		zesp delta_a_1=R_a;
		  
		zesp delta_a_4= V_a/(1.-V_a*H_pp_a);
		zesp delta_l_1=(R_l+R_la*H_rr_l*R_a)/(1. - R_la*H_rr_l );
		  
		zesp licznik_delta_l_4 =V_l+V_la*H_pp_l*V_a;
		zesp mianownik_delta_l_4 = (1.0 - V_a*H_pp_a )*(1.0 - V_la*(H_pp_l+H_pp_a));
		zesp delta_l_4=licznik_delta_l_4/mianownik_delta_l_4;

		 
		zesp licznik_delta_t_1=(1.- V_ta*(H_pp_a+H_pp_t)) *( R_t + R_a* R_ta*H_rr_t  )
								+R_a*R_ta*V_ta*pow(H_rp_va,2);
		zesp mianownik_delta_t_1 = (1. - V_ta*(H_pp_a + H_pp_t))*(1. - R_ta*H_rr_t) - R_ta*V_ta*pow(H_rp_va,2);
		zesp delta_t_1 = licznik_delta_t_1/mianownik_delta_t_1;
		 
		zesp licznik_delta_t_4 =(1. - R_ta*H_rr_t)*(V_t +delta_a_4*(V_ta*H_pp_t+V_t*H_pp_a))
											 +delta_a_4*R_ta*V_ta*pow(H_rp_va,2);
		zesp mianownik_delta_t_4= (1. - V_ta*(H_pp_a + H_pp_t ) )*(1. - R_ta*H_rr_t)- R_ta*V_ta*pow(H_rp_va,2);
		zesp delta_t_4 =licznik_delta_t_4/mianownik_delta_t_4;
		 

		 
		zesp delta_va_2=R_ta*H_rp_va*(delta_t_4+delta_a_4)/(1. - R_ta*H_rr_t );
		 
		zesp delta_va_3=V_ta*H_rp_va*( R_a + delta_t_1)/(1. - V_ta*(H_pp_a + H_pp_t) );


		double poprawka_a=imag(delta_a_4*H_p_a*H_p_a);

		double poprawka_l= imag( ( delta_a_4+delta_l_4)*(pow(H_p_l ,2) + 2.*H_p_l*H_p_a ))
					   +imag( pow(H_p_a,2 )*delta_l_4 + pow( H_r_l,2 )*( delta_a_1+delta_l_1));

		double poprawka_t =  imag((pow(H_p_t,2) + 2.*H_p_t*H_p_a +pow(H_p_va,2))*
						(delta_a_4 +delta_t_4) + delta_t_4*pow(H_p_a,2))+
							imag((pow(H_r_t,2) + pow(H_r_va,2))*(delta_t_1+delta_a_1))+				    
							imag( (H_r_va*H_p_t+H_r_va*H_p_a+H_r_t*H_p_va)*(delta_va_2+delta_va_3));
			   
		double poprawka_va = imag((H_r_t*H_p_t + H_r_t*H_p_a+H_r_va*H_p_va)*(delta_va_2 + delta_va_3))   
							+2.*imag( H_p_va*( H_p_t+H_p_a )*( delta_t_4 + delta_a_4)
						  +H_r_va*H_r_t*(delta_t_1 + delta_a_1));
		double R_L[2],R_T[2],R_A[2],R_VA[2];  
		
		R_L[0]=( F_1_*F_1_ + G_A_*G_A_ )*Im_H_vv_l+ F_2_*F_2_*Im_H_tt_l+ 2*F_1_*F_2_*Im_H_vt_l;
		
		R_L[1]=R_L[0] + poprawka_l;

		R_T[0]=Im_H_vv_t*(G_A_*G_A_+ F_1_*F_1_)/2 + Im_H_tt_t*F_2_*F_2_/2 + F_1_*F_2_*Im_H_vt_t;

		R_T[1]=R_T[0] - poprawka_t; 

		R_A[0]=G_A_*G_A_*Im_H_a;

		R_A[1]=R_A[0]  + poprawka_a;

		R_VA[0]=(F_1_+Mef/M*F_2_)*G_A_*Im_H_va;
		
		R_VA[1]=R_VA[0] +poprawka_va/2.0;   /// UWAGA TUTAJ BYL BLAD, TRZEBA PODZIELIC PRZEZ 2!

		
		double L_L=-(16*En*(En-q0)-4*(mm-q2))*q2/qv2 - 4*mm*q0*(4*En - q0 + q0*mm/q2 )/qv2;

		double L_T=-(16*En*(En-q0)-4*(mm-q2))*q2/qv2 
					- 4*mm*(4*En*q0- (q0*q0-qv*qv) + mm)/qv2 - 8*(q2-mm);

		double L_A=8*(q2-mm);

		double L_VA=-16*(q2*(2*En-q0) + q0*mm)/qv;


		double amplituda[2];
		amplituda[0]=    L_L*R_L[0] +(L_A+L_T)*R_A[0] + L_T*(R_T[0] -R_A[0]) -znak*L_VA*R_VA[0];   
		amplituda[1]=    L_L*R_L[1] +(L_A+L_T)*R_A[1] + L_T*(R_T[1] -R_A[1]) -znak*L_VA*R_VA[1];   
	  
/*	  if(amplituda[0] > 0 || amplituda[1] > 0)
		  cerr<<"amplituda zla( E="<< En/GeV 
			  <<", q0 = "<< q0/GeV<<", Q2 = " 
			  << (qv*qv-q0*q0)/GeV/GeV 
			  << ", (En-q0)*(En-q0)-mm = " << 
		  ((En-q0)*(En-q0)-mm)/GeV/GeV<<") mm="<<mm<<endl;
*/		 if(!ratio)
		  return 2*max(-amplituda[use_rpa]*stala*stala * qv /(16 * Pi * Pi * (kf*kf*kf/3/Pi/Pi)  * En * En)/cm2,0.);
		 else
		  return amplituda[0]>0 ? min(amplituda[1]/amplituda[0],10.0) :1;
	}

	double sigma_q0( double q0)
	{ 

		if( (En-q0)*(En-q0)-mm < 0 )
		{ 
			return 0; cerr<<"amplituda nie liczona"<<endl;
		}
		else   
			return  calg5a(fix2(sigma_qv_q0,q0),qMin(q0),qMax(q0),100);
	}    
	double sigma_q0_new( double q0)
	{ 

		if( (En-q0)*(En-q0)-mm < 0 )
		{ 
			return 0; cerr<<"amplituda nie liczona"<<endl;
		}
		else   
			return  calg5a(fix2(Przekroj,q0),qMin(q0),qMax(q0),100);
	}    


	void configure(double E, const int kNucleus, int nu_pdg, int use_Mf, int kFF0,double kf0, double mf0)
	{
		En = E;  
		kFF=kFF0;

		kf = kf0>0 ? kf0 : mean_kf(kNucleus);       
		Mef = use_Mf ? Masa_Efektywna(kf) : M; 
		Mef2=Mef*Mef;              		
		Ef= sqrt(kf*kf + Mef2);   
		Ef2=kf*kf + Mef2;
		
		znak=nu_pdg>0 ? 1 :-1;
		switch(nu_pdg)
		{ 
			case 12:case -12: m=m_e;break;
		  	case 14:case -14: m=m_mu;break;
		  	case 16:case -16: m=m_tau;break;
		  	default: m=0;break;
	    }
		mm=m*m;
	}   
	

	double sigma_q0_q2(double q0,double q2)
	{
		double qv=sqrt(q2+q0*q0);
		return (sigma_qv_q0(qv,q0)/2/qv);
	}

	double sigma_q2(double q2)
	{   
		double q01 =0;
		double q02 = En - (q2+mm)/4/En - En*mm/(q2+mm);
		return calg5a(fix2(sigma_q0_q2,q2),min(q01,q02),max(q01,q02),100);
	}    



	void plot_sigma_q2(double E, int ilosc,const int kNucleus, int nu_pdg, int use_Mf, int kFF0=0,double kf0=0 )
	{   
		configure(E, kNucleus, nu_pdg, use_Mf, kFF0,kf0);

		stringstream s;
		
		s<<"rpa_Q2_"<<nazwa_jadra(kNucleus)<<",nu="<<nu_pdg<<",E="<<En/GeV<<",rpa="<<use_rpa+2*use_Mf<<",g="<<g_prim
		 <<",kfsr="<<kf<<",Mef="<<Mef<<','<<form(kFF)<<".dat"<<flush;
		
		ofstream out(s.str().c_str());

		double krok= 2*M*(En-m)/ilosc;
		
		double frac=0;
        switch(kNucleus)
        {
			case C:
			case O: frac= 0.5;break;
			case Ar:frac= 18./40.;break;
			case Fe:frac= 26./56.;break;
			case n: frac= 0;break;
		}
		if(nu_pdg>0)
			frac=1-frac;
		
		for(double q2 =0.01; q2<2*M*(En-m); q2+=krok)
		{
			out<< q2/GeV/GeV   <<"\t"<<frac*GeV2*sigma_q2(q2)/1e-38 << endl;
		}
	}   

	void plot_sigma_q0(double E, int ilosc,const int kNucleus, int nu_pdg, int use_Mf, int kFF0,double kf0=0 )
	{
		 configure(E, kNucleus, nu_pdg, use_Mf, kFF0,kf0);

		 stringstream s;

//		 s<<"rpa_q0_"<<nazwa_jadra(kNucleus)<<",E="<<En/GeV
//		  <<",g="<<g_prim<<",kfsr="<<kf<<",Mef="<<Mef<<form(kFF)<<",rpa="<<use_rpa<<",nu="<<nu_pdg<<".dat"<<flush;
		 s<<"rpa_q0_"<<nazwa_jadra(kNucleus)<<",nu="<<nu_pdg<<",E="<<En/GeV<<",rpa="<<use_rpa+2*use_Mf<<",g="<<g_prim
		 <<",kfsr="<<kf<<",Mef="<<Mef<<','<<form(kFF)<<".dat"<<flush;
		ofstream out(s.str().c_str());
		double frac=0;
        switch(kNucleus)
        {
			case C:
			case O: frac= 0.5;break;
			case Ar:frac= 18./40.;break;
			case Fe:frac= 26./56.;break;
			case n: frac= 0;break;
		}
		if(nu_pdg>0)
			frac=1-frac;
//		for(double q0=5*MeV; q0 < En-m; q0+=(En-m)/ilosc)
		for(double q0=0.001*MeV; q0 < En-m; q0+=6*MeV)
		{	
			double a=sigma_q0(q0);
			double b=sigma_q0_new(q0);
			out<< q0/GeV <<' ' <<b/a<<' '<<frac*b*GeV/(1e-38)<<' '<<frac*a*GeV/(1e-38)<<endl;
		}
	}


	void plot_ratio_q2(double E, int ilosc,const int kNucleus, int nu_pdg, int use_Mf, int kFF0=0,double kf0=0 )
	{   
		configure(E, kNucleus, nu_pdg, use_Mf, kFF0,kf0);

		stringstream s;
		
		s<<"ratio_Q2_"<<nazwa_jadra(kNucleus)<<",nu="<<nu_pdg<<",E="<<En/GeV<<",g="<<g_prim
		 <<",kfsr="<<kf<<",Mef="<<Mef<<','<<form(kFF)<<".dat"<<flush;
		
		ofstream out(s.str().c_str());

		double krok= 2*M*(En-m)/ilosc;
        bool prev_rpa=use_rpa;				
		for(double q2 =0.01; q2<2*M*(En-m); q2+=krok)
		{	

			use_rpa=false;
			double sig0=sigma_q2(q2);
			use_rpa=true;
			double sig1=sigma_q2(q2);
			out<< q2/GeV/GeV   <<"\t"<< min(10.,(sig0>0 && sig1>=0 ? sig1/sig0 : 1)) << endl;
		}
		use_rpa=prev_rpa;
	}   



	double sigma()
	{
		return calg5a(sigma_q0,0 ,En - m);	
	}
/*		  
	double sigma_Atom(double E,int kNucleus, int nu_pdg, double dokl, int use_Mf, int kFF0, double kf0)
	{

		configure(E, kNucleus, nu_pdg, use_Mf, kFF0,kf0);

		return 0.5*liczba_atomowa(kNucleus)*sigma();      
	}

		  
	void plot_sigma(double zakres,double krok, int kNucleus,int nu_pdg,double dokl,int use_Mf,int kFF0, double kf0=0 )
	{  
	  
		configure(m+50*MeV, kNucleus, nu_pdg, use_Mf, kFF0,kf0);

		string s2=znak>0? "_n":"_an";
		 
		stringstream s;
		s<<"rpa_cal_"<<nazwa_jadra(kNucleus)<<"_g="<<g_prim<<"kfsr="<<kf<<"Mef="
		 <<Mef<<s2<<form(kFF)<<".dat"<<flush;
		
		ofstream out(s.str().c_str());
		
		for(double En =  m+50*MeV; En<zakres ;En+=krok)
			out<< En/GeV  <<' '<<0.5*liczba_atomowa(kNucleus)*sigma()/(1e-38)<<endl;
	}
*/
	double Przekroj(double qv,double q0);
	
	double ratio_rpa_fg(int qel_rpa, double q0, double qv)//, double kf0, int kFF0=0,int nu_pdg=1,int kNucleus=0, bool use_Mf0=0)
	{

//		configure(E, kNucleus, nu_pdg, use_Mf0, kFF0, kf0);
	    switch(qel_rpa)
	    {	
			case 0:return 1;
			case 1:
			{
				ratio=true;
				double res=sigma_qv_q0(qv,q0);
				ratio=false;
				return res;
			}
			case 2:
			{
				ratio=false;
				use_rpa = true;
				double sigma_rpa=sigma_qv_q0(qv,q0);
				use_rpa = false; 
				double sigma_fg=sigma_qv_q0(qv,q0);
				return sigma_fg ? sigma_rpa/sigma_fg : 1;
			}
			default: return 1;
		}
	}


double Przekroj(double qv,double q0)
{
	double ro=(kf*kf*kf)/(3*Pi*Pi);
	double q2=q0*q0-qv*qv;
	double qv2= qv*qv;
	double q02= q0*q0;

	/// Czynniki postaci
	int FF=Dipol;
	
	double F1 = F_1(q0,qv,FF);
	double F2 = F_2(q0,qv,FF);
	double GA = G_A(q0, qv,FF);
	double Fp = F_p(q0, qv,FF);

	/// tensor leptonowy

	double L_L_ = -(16*En*(En-q0)-4*(mm2-(q0*q0-qv*qv) ) )*(q0*q0-qv*qv)/(qv*qv)
		-4*mm2*q0*(4*En - q0 + q0*mm2/(q0*q0-qv*qv) )/(qv*qv);

	double L_T_ = -(16*En*(En-q0)-4*(mm2-(q0*q0-qv*qv)))*(q0*q0-qv*qv)/(qv*qv)
		- 4*mm2*(4*En*q0- (q0*q0-qv*qv) + mm2)/(qv*qv) -8*((q0*q0-qv*qv)-mm2);

	double L_A_   = 8*((q0*q0-qv*qv)-mm2);

	double L_VA_ = -16*((q0*q0-qv*qv)*(2*En-q0) + q0*mm2)/qv;

	//// tensory

	//--------------------------------------------------------------------------
	// Wprowadzamy funkcje okreslajace czesci rzeczywiste
	//--------------------------------------------------------------------------

	double licznikalfa = fabs(q2*q2 - 4*pow( q0*Ef - qv*kf, 2 ) );
	double mianownikalfa =fabs(q2*q2 - 4*pow(q0*Ef + qv*kf,  2));
	double alfa_= log(licznikalfa/mianownikalfa );

	double licznikbeta =fabs((pow(q2 + 2*qv*kf, 2) - 4*q02*Ef2));
	double mianownikbeta =fabs(pow(q2 - 2*qv*kf, 2) - 4*q02*Ef2 );
	double beta_ = log(licznikbeta/mianownikbeta ) ;

	double stalLAMBDA=sqrt(q2*(q2 -4*Mef2));
	double licznik1LAMBDA =      fabs(q2*q2*Ef - 4*q0*Mef2*(q0*Ef-qv*kf) - kf*q2*stalLAMBDA);
	double Mianownik1LAMBDA=fabs(q2*q2*Ef - 4*q0*Mef2*(q0*Ef-qv*kf) + kf*q2*stalLAMBDA);
	double licznik2LAMBDA =      fabs(q2*q2*Ef - 4*q0*Mef2*(q0*Ef+qv*kf) - kf*q2*stalLAMBDA);
	double Mianownik2LAMBDA=fabs(q2*q2*Ef - 4*q0*Mef2*(q0*Ef+qv*kf) + kf*q2*stalLAMBDA);

	double LAMBDA_=0;

	if(q2==0) { LAMBDA_ = 0;}
	else
	{
		LAMBDA_= (log(licznik1LAMBDA/Mianownik1LAMBDA )
			+         log(licznik2LAMBDA/Mianownik2LAMBDA)  )/2./stalLAMBDA;
	}

	////// ----------- Pomocnicze  Czesci rzeczywiste ----------////////

	double nawiasReHs = kf*Ef - (3*Mef2 - q2/2)*log((kf+Ef)/Mef) -
		q0*(4*Mef2-q2)*alfa_ /8/qv +
		Ef*(4*Mef2-q2)*beta_  /4/qv +
		(4*Mef2-q2)*(4*Mef2-q2)*LAMBDA_/4;

	double ReHs_= lambda_l*nawiasReHs /(2*Pi*Pi);

	double nawiasReHl= 2*kf*Ef/3 - (qv2/6)*log((kf+Ef)/Mef) +
		(q0/(4*qv))*(Ef2 + (q02-3*qv2)/12 )*alfa_
		- Ef*(3*q2 + 4*Ef2)*beta_/(24*qv)
		+ qv2*(2*Mef2+q2)*(4*Mef2-q2)*LAMBDA_/(12*q2) ;

	double ReHl_= nawiasReHl*lambda_l*q2/(Pi*Pi*qv2);

	double nawiasReHt= kf*Ef*(1+ 2*q02/qv2 )/3 + (q2/3)*log((kf+Ef)/Mef)
		+ (q0*q2/(4*qv2*qv))*((q02 + 3*qv2)/12 + qv2*Mef2/q2+ Ef2)*alfa_
		+ (Ef/qv)*((qv2*qv2-q02*q02)/(8*qv2) - Mef2/2 - q2*Ef2/(6*qv2))*beta_
		-  (2*Mef2+q2)*(4*Mef2 - q2)*LAMBDA_/6;

								 // tutaj przemnozylem przez 2
	double  ReHt_= 2*nawiasReHt*lambda_l/(2*Pi*Pi);

	double nawiasReH0 = qv*kf + q0*Ef*alfa_/2
		-(q2/8 + Ef2/2 + qv2*Mef2/(2*q2))*beta_;

	double ReH0_= nawiasReH0 * lambda_l*Mef/(2*Pi*Pi*qv);

	// -------------------------------------------------------------------------

	double E_max_ = max3( Mef , Ef - q0, 0.5*(- q0+qv * sqrt(1-4*Mef2/q2 )));

	double E__ = min(Ef, E_max_);

	double E1_ = Ef - E__;

	double E2_ = (Ef*Ef -E__*E__)/2;

	double E3_=  (Ef*Ef*Ef -E__*E__*E__)/3;

	//              Czesci Rzeczywiste tensorw Hadronowych

	//                        ------------------

	double Re_H_a_ =  ( - 2*ReHs_ - ReHl_ + ReHt_)/3;

	double Re_H_vv_l_= ReHl_;

	double Re_H_vv_t_= ReHt_;

	double Re_H_va_= (q0*q0-qv*qv)*ReH0_/2/qv/qv/Mef;

	double Re_H_tt_l_=  (q0*q0-qv*qv)*(-ReHl_ + ReHs_ - 2*ReHt_)/ (12 * M*M)  ;

	double nawias1_Re_H_tt_t = ReHl_*(q2 - 8*Mef2) + ReHt_*(2*Mef2 - q2)
		+ 2*ReHs_*(q2-2*Mef2);
	double nawias2_Re_H_tt_t = q2*ReH0_ - 2*qv*qv*Mef*Re_H_va_;
	double Re_H_tt_t_ =  q2*(nawias1_Re_H_tt_t/24/M/M/Mef2 + nawias2_Re_H_tt_t/4/q0/M/M/Mef);

	double Re_H_vt_l_ =-q2*Re_H_a_/(4*M*Mef);

	double Re_H_vt_t_= (q0*q0-qv*qv)*Re_H_a_/(2*M*Mef) ;

	double Re_H_ppf_l_= ReHs_ +0.5*Re_H_a_;

	double Re_H_ppf_t_= ReHs_ +0.5*Re_H_a_;

	double Re_H_ppf_a_= ReHs_ +0.5*Re_H_a_;

	double Re_H_apf_l_=  0.5*Re_H_a_/Mef;

	double Re_H_apf_t_= 0.5*Re_H_a_/Mef;

	double Re_H_apf_a_= 0.5*Re_H_a_/Mef;

	//    ----------------------------------------------------------------------

	//                   Czesci Urojone tensorow Hadronowych

	//                   -----------------------------------

	double Im_H_vv_l_= ((q0*q0-qv*qv)/(2*Pi*qv*qv*qv))*
		( E3_ + q0*E2_ + (q0*q0-qv*qv)*E1_/4 ) ;

								 // dwojka
	double Im_H_vv_t_= 2*((q0*q0-qv*qv)/(4*Pi*qv*qv*qv))*
		(E3_+q0*E2_+(qv*qv*Mef2/(q0*q0-qv*qv)+0.25*(q0*q0+qv*qv))*E1_) ;

	double Im_H_tt_l_=  - ( ( q0*q0-qv*qv )/( 8*Pi*qv*qv*qv*M*M))*
		( (q0*q0-qv*qv)*E3_ + q0*(q0*q0-qv*qv)*E2_+
		( qv*qv*Mef2 +0.25*(q0*q0-qv*qv)*q0*q0 )*E1_ );

								 // bylo 16 zamiast 8;
	double Im_H_tt_t_ =( (q0*q0-qv*qv)/(8*Pi*qv*qv*qv*M*M) )*

		( ( Mef2*qv*qv - 0.25*(q0*q0-qv*qv)*(q0*q0-qv*qv) )*E1_

		- q0*(q0*q0-qv*qv)*E2_ -(q0*q0-qv*qv)*E3_ ) ;

	double Im_H_vt_l_= -( (q0*q0-qv*qv)*E1_ *Mef )/(8*Pi*qv*M);

								 // dwojka
	double Im_H_vt_t_= -2*Im_H_vt_l_;

	double Im_H_va_ = qv*((q0*q0-qv*qv)/(8*Pi*qv*qv*qv))*(2*E2_ + q0*E1_);

	double Im_H_a_= (Mef2 * E1_ )/(2*Pi*qv);

	double Im_H_pp_ = (q0*q0-qv*qv)*E1_/8/Pi/qv ;

	double Im_H_ap_ =  Mef*E1_/4/Pi/qv;

	// --------------------------------------------------------------------------
	//           Wprowadzamy kompletne postacie Tensorw Hadronowych
	//           ----------------------------------------------------------------

	zesp H_vv_l_=  zesp(Re_H_vv_l_,Im_H_vv_l_);

	zesp H_vv_t_=  -0.5* zesp(Re_H_vv_t_,Im_H_vv_t_);

	zesp H_tt_l_=   zesp(Re_H_tt_l_,Im_H_tt_l_);

	zesp H_tt_t_ = -0.5*zesp(Re_H_tt_t_,Im_H_tt_t_);

	zesp H_vt_l_= zesp(Re_H_vt_l_,Im_H_vt_l_) ;

	zesp H_vt_t_= -0.5*zesp(Re_H_vt_t_,Im_H_vt_t_);

								 // czesc urojona pomnozylem przez
	zesp H_va_=   zesp(qv*Re_H_va_, Im_H_va_) ;
								 // qv wczaesniej w definicji Im

	zesp H_a_=  zesp(Re_H_a_,Im_H_a_);

	zesp H_apf_l_=-(q0*q0-qv*qv)*0.5*zesp(Re_H_a_,Im_H_a_)/Mef;

	zesp H_apf_t_= -(q0*q0-qv*qv)*0.5*zesp(Re_H_a_,Im_H_a_)/Mef;

	zesp H_apf_a_=(q0*q0-qv*qv)*0.5*zesp(Re_H_a_,Im_H_a_)/Mef;

	//    -----------------------------------------------------------------------

	zesp H_rr_l_ = (gr2*H_vv_l_*2. + fr*gr*H_vt_l_ + fr2*H_tt_l_/2.);

	zesp H_rr_t_ = (gr2*H_vv_t_/2. + fr*gr*H_vt_t_ + fr2*H_tt_t_/2.);

	zesp H_rp_va_ =  -fpi*(gr + fr *Mef/M)*H_va_/m_pi;

	zesp H_pp_l_ =  2.*fpi2*H_vv_l_/m_pi2;

	zesp H_pp_t_ = 2.*fpi2*H_vv_t_/m_pi2;

	zesp H_pp_a_ = 2.*fpi2*H_a_/m_pi2;

	//-----------------------------// PROPAGATORY SWOBODNE  //-----------------------------------------------//

	double V_l_ = - q2/(q2 - m_pi2);;

								 // zmiana znaku dla elemenu macierzowego
	double V_t_ = -q2/(q2 - m_pi2);

	double V_a_ = q2/(q2 - m_pi2) - g_prim;

	double R_l_ = -q2/(q2 - m_r2)/m_r2;

								 // zmiana znaku dla elemenu macierzowego
	double R_t_ = -q2/(q2 - m_r2)/m_r2;

	double R_a_ = 1/m_r2;

	//--------------------------------------// Tensory Pi  i  Rho  //-------------------------------------------//

	zesp H_r_l_= gr*(F1*H_vv_l_ + F2*H_vt_l_)/sqrt(2)+
		fr*(F1*H_vt_l_ + F2*H_tt_l_)/sqrt(2);

	zesp H_r_t_ =  gr*(F1*H_vv_t_ + F2*H_vt_t_)/sqrt(2)
		+ fr*(F1*H_vt_t_ + F2*H_tt_t_)/sqrt(2);

	zesp H_r_va_ = GA*(gr+fr*Mef/M)*H_va_/sqrt(2);

	zesp H_p_l_ = -sqrt(2)*fpi*(GA*H_vv_l_+Fp*H_apf_l_)/m_pi;

	zesp H_p_t_ =  -sqrt(2)*fpi*( GA*H_vv_t_+Fp*H_apf_t_ )/m_pi;

	zesp H_p_a_ = -sqrt(2)*fpi*( H_a_*GA+Fp*H_apf_a_ )/m_pi;

	zesp H_p_va_ = -sqrt(2)*fpi*(F1+F2*Mef/M)*H_va_/m_pi;

	////   delty

	zesp delta_a_1_ = R_a_;

	zesp delta_a_4_ = V_a_/(1.-V_a_*H_pp_a_);

	zesp delta_l_1_ = (R_l_+(R_l_+R_a_)*H_rr_l_*R_a_)/
		(1. - (R_l_+R_a_)*H_rr_l_ );

	zesp licznik_delta_l_4 =V_l_+( V_l_+V_a_ )*H_pp_l_*V_a_;
	zesp mianownik_delta_l_4 = (1. - V_a_*H_pp_a_ )*(1. - (V_l_+V_a_)*(H_pp_l_+H_pp_a_));
	zesp delta_l_4_ = licznik_delta_l_4/mianownik_delta_l_4;

	zesp R_ta =R_t_+R_a_;		 ///
	zesp V_ta =V_t_+V_a_;		 ///

	zesp licznik_delta_t_1 =(1.- V_ta*(H_pp_a_+H_pp_t_)) *( R_t_ + R_a_* R_ta*H_rr_t_  )
		+ R_a_*R_ta*V_ta*pow(H_rp_va_,2);

	zesp mianownik_delta_t_1 = (1. - V_ta*(H_pp_a_ + H_pp_t_ )) *(1. - R_ta*H_rr_t_)
		- R_ta*V_ta*pow(H_rp_va_,2);

	zesp delta_t_1_ = licznik_delta_t_1/mianownik_delta_t_1;

	zesp licznik_delta_t_4 = (1. - R_ta*H_rr_t_ )*
		( V_t_ +delta_a_4_*(V_ta*H_pp_t_ + V_t_*H_pp_a_))
		+ delta_a_4_*R_ta*V_ta*pow(H_rp_va_,2);

	zesp mianownik_delta_t_4= (1. - V_ta*(H_pp_a_ + H_pp_t_ ) )*(1. - R_ta*H_rr_t_)
		- R_ta*V_ta*pow(H_rp_va_,2);

	zesp delta_t_4_ = licznik_delta_t_4/mianownik_delta_t_4;

	zesp delta_va_2_ = R_ta*H_rp_va_*(delta_t_4_+delta_a_4_)/
		(1. - R_ta*H_rr_t_ );

	zesp delta_va_3_ =  V_ta*H_rp_va_*( R_a_ + delta_t_1_)/(1. - V_ta*(H_pp_a_ + H_pp_t_) );

	//// Poprawki RPA
	double poprawka_l_ =  imag( ( delta_a_4_+delta_l_4_)*(H_p_l_*H_p_l_  + 2.*H_p_l_*H_p_a_ ))
		+imag( H_p_a_*H_p_a_*delta_l_4_ + H_r_l_*H_r_l_*( delta_a_1_+delta_l_1_));

	double poprawka_t_ = imag((pow(H_p_t_,2) + 2.*H_p_t_*H_p_a_ +pow(H_p_va_,2))*
		(delta_a_4_ +delta_t_4_) + delta_t_4_*pow(H_p_a_,2))
		+
		imag((pow(H_r_t_,2) + pow(H_r_va_,2))*(delta_t_1_+delta_a_1_))
		+
		imag( (H_r_va_*H_p_t_+H_r_va_*H_p_a_+H_r_t_*H_p_va_)*
		(delta_va_2_+delta_va_3_));

	double poprawka_a_ = imag(delta_a_4_*H_p_a_*H_p_a_);

	double poprawka_va_ = imag((H_r_t_*H_p_t_ + H_r_t_*H_p_a_+H_r_va_*H_p_va_)*
		(delta_va_2_ + delta_va_3_)) +
		2.*imag( H_p_va_*( H_p_t_+H_p_a_ )*( delta_t_4_ + delta_a_4_)
		+H_r_va_*H_r_t_*(delta_t_1_ + delta_a_1_));

	//poprawka_va = imag((H_r_t*H_p_t + H_r_t*H_p_a+H_r_va*H_p_va)*(delta_va_2 + delta_va_3))
	//                        +2.*imag( H_p_va*( H_p_t+H_p_a )*( delta_t_4 + delta_a_4)
	//		              +H_r_va*H_r_t*(delta_t_1 + delta_a_1));
	//----------------------------------------------------------------------------

	/// Tensory odpowiedzi
	double R_L_ = ( F1*F1 + GA*GA )*Im_H_vv_l_+
		F2*F2*Im_H_tt_l_+
		2*F1*F2*Im_H_vt_l_
		-q2*Fp*Fp*Im_H_pp_
		-2*q2*GA*Fp*Im_H_ap_
		+ use_rpa*poprawka_l_;

	double R_T_= Im_H_vv_t_*(GA*GA+ F1*F1)/2
		+ Im_H_tt_t_*F2*F2/2
		+ F1*F2*Im_H_vt_t_
		+ q2*Fp*Fp*Im_H_pp_
		+ 2*q2*GA*Fp*Im_H_ap_
		-  use_rpa*poprawka_t_;

	double R_A_ = pow(GA,2)*Im_H_a_ + q2*pow(Fp,2)*Im_H_pp_
		+ 2*q2*GA*Fp*Im_H_ap_
		+  use_rpa*poprawka_a_;

	double R_VA_ = ( F1 +  Mef*F2/M )*GA*Im_H_va_
								 //wydaje sie ze musi tu byc 0.5 bo tensor leptonowy jest tak unormowany
		+ 0.5*use_rpa*poprawka_va_;

	double Amplituda=   L_L_*R_L_
		+ L_T_*R_T_
		+ L_A_*R_A_
		-znak*L_VA_*R_VA_;

	if(Amplituda > 0)
		cerr<<"amplituda zla( q0="
			<< q0/GeV<<" qv="<<qv/GeV<<','<<-Amplituda*(stala*stala * qv )/(16 * Pi * Pi * ro  * En * En)*GeV/cm2<<')'<<endl;

	return -Amplituda*(stala*stala * qv )/(16 * Pi * Pi * ro  * En * En)*GeV/cm2;
}



}


//#ifdef RPA_MAIN

using namespace rpa;

void porownanie(double E,double q0)
{	
	En=E;
	if( (En-q0)*(En-q0)-mm2 < 0 )
	{ 
		cerr<<"amplituda nie liczona"<<endl;
		return ; 
	}
	double qmin=qMin(q0),qmax=qMax(q0);
	//~ cout <<"Ola"<<endl;
	//~ cout <<"qmin="<<qmin<<endl;
	//~ cout <<"qmax="<<qmax<<endl;
	for(double q=qmin;q<qmax;q+=(qmax-qmin)/30)
	{
		double old=sigma_qv_q0(q,q0);
		double news=Przekroj(q,q0);
		if(news!=0 || old !=0)
		cout <<q0<<' '<<q<<' '<<Przekroj(q,q0)/sigma_qv_q0(q,q0)/500<<' '<<Przekroj(q,q0)<<' '<<sigma_qv_q0(q,q0) <<endl;//<<endl;
	}
}


int main()
{   int Atoms[]={0,6,8,18,26};
	
    int FF=Dipol;	
//    porownanie(1*GeV);	
    for(double q0=0;q0<1*GeV;q0+=1)
		porownanie(1*GeV,q0);
//~ //    if(false)
    //~ for(int i=1;i<2;i++)
	//~ {    
//~ //		for(double Enu=0.2*GeV;Enu<=5*GeV;Enu+=0.2*GeV)
		//~ for(double Enu=1*GeV;Enu<=1*GeV;Enu+=0.2*GeV)
		//~ {
			//~ int kNucleus=Atoms[i];
			//~ double kf=225;//mean_kf(kNucleus);
			//~ int nu=14;
			//~ 
			//~ cout<<"Nucleus= "<<nazwa_jadra(kNucleus)<<endl;
			//~ cout<<"kf= "<<kf/MeV<<" MeV"<<endl;
			//~ cout<<"Mf= "<<Masa_Efektywna(kf)/MeV<<" MeV"<<endl;
			//~ cout<<"Meff= "<<Meff(kf)/MeV<<" MeV"<<endl;
			//~ cout<<"E= "<<Enu/MeV<<" MeV"<<endl;
			//~ cout<<"nupdg= "<<nu<<endl;
			//~ 
			//~ for(int i=0;i<4;i++)
			//~ {
				//~ use_rpa=i&1;
				//~ bool use_mf0=i&2;
//~ 
				//~ plot_sigma_q0(Enu,100,kNucleus , nu , use_mf0, FF, kf );
				//~ plot_sigma_q0(Enu,100,kNucleus , -nu , use_mf0, FF, kf );
				//~ plot_sigma_q2(Enu,100,kNucleus, nu, use_mf0, FF,kf);
				//~ plot_sigma_q2(Enu,100,kNucleus, -nu, use_mf0, FF,kf);
				//~ if(use_rpa)
				//~ {
					//~ plot_ratio_q2(Enu,100,kNucleus, nu, use_mf0, FF,kf);
					//~ plot_ratio_q2(Enu,100,kNucleus, -nu, use_mf0, FF,kf);
				//~ }
			//~ }
		//~ }
	//~ }
	//~ if(false)
	//~ {  
//~ //		configure(E, kNucleus, nu_pdg, use_Mf, kFF0,kf0);
		//~ configure(1000, 6, 14, false, Dipol,225);
		//~ for(double q0=0*MeV;q0<rpa::En-rpa::m;q0+=10*MeV)
		//~ {
			//~ for(double qv=rpa::qMin(q0);qv<rpa::qMax(q0);qv+=10*MeV)
			//~ {
				//~ double a=Przekroj(qv,q0);
				//~ if(a==0 || !(a==a)) continue;
				//~ cout<<Przekroj(qv,q0)<<endl;
				//~ cout<<sigma_qv_q0(qv,q0)<<endl;
				//~ cout<<Przekroj(qv,q0)/sigma_qv_q0(qv,q0)<<endl;
				//~ 
				//~ 
				//~ cout<<endl;
				//~ double x=rpa::ratio_rpa_fg(rpa::En, q0, qv);
				//~ if(x==x)
					 //~ cout<<x<<endl;
			//~ }
		//~ }
		                                                          //~ 
		 //~ 
	//~ }
}

//#endif
